package com.zcoj.service;

import com.zcoj.core.model.ApiResponse;
import com.zcoj.core.model.PageData;
import com.zcoj.core.model.PageWrap;
import com.zcoj.pojo.Dto.Problem;
import com.zcoj.pojo.Vo.ProblemCaseVO;
import com.zcoj.pojo.Vo.ProblemPageVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

/**
 * Service定义
 * @author 剩xia的盛夏
 * @date 2023/02/24 16:16
 */

@CacheConfig(cacheNames = "ProblemService")
public interface ProblemService {




    /**
     * 创建
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @CacheEvict(value = "ProblemService",allEntries = true)
    Integer create(Problem problem);



    @Cacheable(key = "#p0.toString()+'isProblemValidID'")
    Boolean isProblemValidID(Integer pid);


    @Cacheable(key = "'getProblemList'")
    List<Problem> getProblemList();

    /**
     * 主键删除
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    @CacheEvict(value = "ProblemService",allEntries = true)
    Integer deleteById(Integer id);

    /**
     * 批量主键删除
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    @CacheEvict(value = "ProblemService",allEntries = true)
    void deleteByIdInBatch(List<Integer> ids);

    /**
     * 主键更新
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    @CacheEvict(value = "ProblemService",allEntries = true)
    Integer updateById(@Param("problem") Problem problem);

    /**
     * 批量主键更新
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    @CacheEvict(value = "ProblemService",allEntries = true)
    void updateByIdInBatch(List<Problem> problems);

    /**
     * 主键查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    @Cacheable(key = "#p0.toString()+'findById'")
    Problem findById(Integer id);

    /**
     * 条件查询单条记录
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()+'findOne'")
    Problem findOne(Problem problem);

    /**
     * 条件查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()+'findList'")
    List<Problem> findList(Problem problem);
  
    /**
     * 分页查询
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */

    @Cacheable(key = "#p0.toString()+'findPage'")
    PageData<Problem> findPage(PageWrap<Problem> pageWrap);


    @Cacheable(key = "#p0.toString()+'findPageVO'")
    PageData<ProblemPageVO> findPageVO(PageWrap<Problem> pageWrap);




    @Cacheable(key = "#p0.toString()+'findComponentPageVO'")
    PageData<ProblemPageVO> findComponentPageVO(PageWrap<Problem> pageWrap);

    /**
     * 条件统计
     * @author 剩xia的盛夏
     * @date 2023/02/24 16:16
     */
    long count(Problem problem);

    ApiResponse getProblemSource();

    ApiResponse getProblemTag();


    Integer newProblemTestcaseFile(String fileName, Integer pid);

    public void writeProblemCase(ProblemCaseVO problemCaseVO);
}
